import { reqGetGoodsListInfo } from '@/api/index'

const state = {
    goodsListInfo: {}
}
const mutations = {
    SET_GOODLISTINFO(state, goodsListInfo) {
        state.goodsListInfo = goodsListInfo
    }
}
const actions = {
    async get_goodsListInfo({ commit }, searchParams) {
        try {
            let result = await reqGetGoodsListInfo(searchParams)
            if (result.code === 200) {
                commit('SET_GOODLISTINFO', result.data)
            } else {
                alert('获取商品列表失败')
            }
        } catch (error) {
            alert('请求获取商品列表失败')

        }
    }
}
const getters = {
    attrsList(state) {
        return state.goodsListInfo.attrsList || []
    },
    goodsList(state) {
        return state.goodsListInfo.goodsList || []
    },
    trademarkList(state) {
        return state.goodsListInfo.trademarkList || []
    }
}
export default {
    state,
    mutations,
    actions,
    getters
}